package models;

import com.avaje.ebean.Ebean;
import com.avaje.ebean.Model;
import com.avaje.ebean.SqlUpdate;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import play.data.format.Formats;
import play.data.validation.Constraints;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;

/**
 * Category entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "category")
public class Category extends Model{

    @Id
    @Constraints.Min(10)
	public Long categoryId;

    @Constraints.Required
    @Column(unique = true)
	public String categoryName;

	public String categoryDes;

    @Formats.DateTime(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date categoryCreatetime;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "category")
    @JsonBackReference
    public Set<Product> products = new HashSet<Product>(0);

    public static Model.Finder<Long, Category> find = new Model.Finder<>(Category.class);

}